//
//  ViewController.m
//  iOS_Lab
//
//  Created by Chenxuhun on 17/4/13.
//  Copyright © 2017年 Chenxuhun. All rights reserved.
//

#import "ViewController.h"


NSString * const C_LabcellID = @"C_LabcellID";

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *labTableView;

@property(nonatomic,strong)NSArray *dataSource;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _labTableView = [[UITableView alloc]init];
    self.view = _labTableView;
    _labTableView.delegate = self;
    _labTableView.dataSource = self;
    [_labTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:C_LabcellID];
    
    _dataSource = @[@"touchEventVc",@"",@""];
    
    // Do any additional setup after loading the view, typically from a nib.
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



#pragma mark tableView dataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _dataSource.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:C_LabcellID forIndexPath:indexPath];
    
    cell.textLabel.text = _dataSource[indexPath.row];
    
    return cell;
}

#pragma mark tableView delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    Class vcClass = NSClassFromString(_dataSource[indexPath.row]);
    if (vcClass) {
        UIViewController *vc = [[vcClass alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
